package com.chen.servicedriveruser.controller;

import com.chen.internalcommon.dto.Car;
import com.chen.internalcommon.dto.ResponseResult;
import com.chen.servicedriveruser.service.CarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chenliuping
 * @since 2022-11-26
 */
@Slf4j
@RestController
public class CarController {
    @Autowired
    private CarService carService;

    /**
     * 添加车辆信息
     * @param car 车辆实体
     * @return
     */
    @PostMapping("/car")
    public ResponseResult addCar(@RequestBody Car car) {
        log.info("car:{}", car);
        return carService.addCar(car);
    }

    /**
     * 根据车辆id查询车辆信息
     * @param carId 车辆id
     * @return
     */
    @GetMapping("/car")
    public ResponseResult getCarById(Long carId) {
        return carService.getCarById(carId);
    }
}
